package com.sweet.git;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Git操作
 *
 * @author limi
 * @date 2023/3/30 19:04
 */
public class GitUtil {
    /**
     * 拉取数据
     *
     * @param path 目录地址
     */
    public static void pull(String path) {
        System.out.println("更新项目：" + path);
        try {
            Process process = Runtime.getRuntime().exec("git pull --rebase", null, new File(path));
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
